﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dao;
using System.Resources;
using System.Globalization;
using common;

namespace GTVAccountingSystem.view.form
{
    public partial class frmPemision : Form
    {
        DataTable dt = new DataTable();
        PermissionDAO permissionDAO = new PermissionDAO();
        ResourceManager rm = Constant.RM;
        CultureInfo culture = Constant.CULTURE;
        public frmPemision(String userLoginID)
        {
            InitializeComponent();
        }
        public void loadAllPermission()
        {
            dt = permissionDAO.getAllPermission();
            DataTable dtLoad = dt;
            dtLoad.Columns.Remove("ID");
            dtLoad.Columns.Remove("Descriptions");
            dtLoad.Columns["FunctionName"].ColumnName = rm.GetString("clnPermissionName", culture);
        }
      
        private void dgvPermission_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            /*DataTable dt = permissionDAO.getPermissionRoleByPermissionID(dt.Rows["RoleName"].ToString());
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                clbRole.Items.Add(rm.GetString(dt.Rows[i]["RoleName"].ToString()), culture);
            }*/
        }

        private void clbRole_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            String status = "0";
            if (((CheckBox)(clbRole.Items[e.Index])).Checked)
                status = "1";
            permissionDAO.setPermissionUserByID(dt.Rows[e.Index]["ID"].ToString(), status);
        }
    }
}
